<?php

/*
* This file is part of the MooTools Autocompleter plugin for Symfony.
* (c) Christophe Benz <cbenz@easter-eggs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/**
 * eeWidgetFormInputMooToolsAutocompleter represents
 * a rich Javascript input text field with autocomplete feature
 *
 * @author     Christophe Benz <cbenz@easter-eggs.com>
 * @author     Benjamin Grandfond <benjamin.grandfond@gmail.com>
 * @version    SVN: $Id: eeWidgetFormDateVlaDatePicker.class.php $
 */
class sfWidgetPartialView extends sfWidgetForm
{
    /**
   * Configures the current widget.
   *
   * Available options:
   *  * response_type: HTML (default), JSON
   *  * url: AJAX URL which returns the results to display
   *  * max_choices: maximum number of choices to display (default 10)
   *  * update_hidden_on_selection: if you want to store
   *    the id of the selected element into an hidden field
   *  * hidden_id: id of the hidden widget which stores the id of the selected element
   *
   * @param array $options     An array of options
   * @param array $attributes  An array of default HTML attributes
   *
   * @see sfWidgetForm
   */
    protected function configure($options = array(), $attributes = array())
    {
        $this->addRequiredOption('partial_name');
        $this->addOption('partial_options',array());
        parent::configure($options, $attributes);
    }

    /**
   * @param  string $name        The element name
   * @param  string $value       The date displayed in this widget
   * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
   * @param  array  $errors      An array of errors for the field
   *
   * @return string An HTML tag string
   *
   * @see sfWidgetForm
   */
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {

        sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
        //link_to($this->getOption('name'),$this->getOption('url'),array('popup' => array('Popup title', 'width=310, height=400, left=320, top=0' ))).
        return get_partial($this->getOption('partial_name'),array_merge($this->getOption('partial_options'),array('name'=>$name,'value'=>$value)));
    }


    public function getStylesheets()
    {
        return array();
    }

    /**
   * Gets the JavaScript paths associated with the widget.
   *
   * @return array An array of JavaScript paths
   */
    public function getJavaScripts()
    {
        return array();
    }
}
